classdef TestSkillDistribution < matlab.unittest.TestCase

    properties
        OriginalPath
        par
        skill_dist
        skill_dist_cal
    end
    
    methods (TestMethodSetup)
        function createFixture(testCase)
            testCase.OriginalPath = path;
            testCase.addTeardown(@path,testCase.OriginalPath);
            
            addpath('../');
            addpath('../../Densities/');
            
            testCase.par = table2struct(readtable(['../parameters/' ...
                                'distributions_par.csv']));
            testCase.skill_dist = SkillDistribution(testCase.par, 'mass', 1);
            testCase.skill_dist_cal = abilityDistFixed();
        end
    end
 
    methods (Test)
        
        function test_constructor(testCase)
            testCase.skill_dist
        end

        function test_f(testCase)
            Y_M = 6.3720;
            Y_R = 11.7917;
            Y_C = 19.6443;
            w = 19.6004;
            
            actVal = testCase.skill_dist.f(w, Y_M, Y_R, Y_C);
            expVal = testCase.skill_dist_cal.f(w, Y_M, Y_R, Y_C,testCase.par);
            testCase.verifyEqual(actVal, expVal, 'AbsTol', 1e-6)
        end        
        
        
        function test_f_M(testCase)
            Y_M = 6.3720;
            Y_R = 11.7917;
            Y_C = 19.6443;
            w = 19.6004;
            
            actVal = testCase.skill_dist.f_M(w, Y_M, Y_R, Y_C);
            expVal = testCase.skill_dist_cal.f_M(w, Y_M, Y_R, Y_C,testCase.par);
            testCase.verifyEqual(actVal, expVal, 'AbsTol', 1e-6)
        end

        
        function test_f_R(testCase)
            Y_M = 6.3720;
            Y_R = 11.7917;
            Y_C = 19.6443;
            w = 19.6004;
            
            actVal = testCase.skill_dist.f_R(w, Y_M, Y_R, Y_C);
            expVal = testCase.skill_dist_cal.f_R(w, Y_M, Y_R, Y_C,testCase.par);
            testCase.verifyEqual(actVal, expVal, 'AbsTol', 1e-6)
        end

        
        function test_f_C(testCase)
            Y_M = 6.3720;
            Y_R = 11.7917;
            Y_C = 19.6443;
            w = 19.6004;
            
            actVal = testCase.skill_dist.f_C(w, Y_M, Y_R, Y_C);
            expVal = testCase.skill_dist_cal.f_C(w, Y_M, Y_R, Y_C,testCase.par);
            testCase.verifyEqual(actVal, expVal, 'AbsTol', 1e-6)
        end               
    end

end
